import request from '../utils/request'


/**
 *  查询用户
 * @param current
 * @param size
 * @param userVo
 * @returns {AxiosPromise}
 */
export const findUserList= (current,size,userVo) => {
    return request({
        url: '/user/findUserPage',
        method: 'post',
        headers: {
            token: localStorage.getItem('JWT_TOKEN')
        },
        params: {
            current,
            size
        },
        data: userVo
    })
}

/**
 * 上传文件 ，更换图片
 * @param file
 * @returns {AxiosPromise}
 */
export const deleteImageFile= (file) => {
    return request({
        url: '/deleteImgFile',
        method: 'post',
        params: {
            file
        }
    })
}

/**
 * 增加用户
 * @param user
 * @returns {AxiosPromise}
 */
export const saveUser = (user) => {
    return request({
        url: '/user/addUser',
        method: 'post',
        data: user
    })
}

/**
 * 更新用户
 * @param user
 * @returns {AxiosPromise}
 */
export const updateUser = (user) => {
    return request({
        url: '/user/updateUser',
        method: 'post',
        data: user
    })
}

/**
 * 删除用户
 * @param id
 * @returns {AxiosPromise}
 */
export  const deleteUser = (id) => {
    return request({
        url: '/user/deleteUser',
        method: 'post',
        params: {
            id
        }
    })
}

/**
 * 根据ID查询用户
 * @param id
 * @returns {AxiosPromise}
 */
export const findUserById = (id) => {
    return request({
        url: '/user/id',
        method: 'get',
        params: {id},
    })
}

/**
 * 获取用户信息
 * @returns {AxiosPromise}
 */
export const getUserInfo = () => {
    return request({
        url: '/getInfo',
        method: 'get'
    })
}